"""
用户搜索记录模型定义
"""

from typing import List, Optional
from pydantic import BaseModel, Field
import time


class UserSearchHistory(BaseModel):
    """用户搜索记录基础模型"""

    user_id: int = Field(..., description="用户ID")
    search_query: str = Field(..., description="搜索关键词")
    created_at: int = Field(
        default_factory=lambda: int(time.time()), description="创建时间戳"
    )
    updated_at: int = Field(
        default_factory=lambda: int(time.time()), description="更新时间戳"
    )


class SearchHistoryRequest(BaseModel):
    """搜索记录插入请求模型"""

    search_query: str = Field(..., description="搜索关键词")


class SearchHistoryListResponse(BaseModel):
    """搜索记录列表响应模型"""

    message: str = Field(..., description="响应消息")
    search_history_list: List[UserSearchHistory] = Field(
        default_factory=list, description="搜索记录列表"
    )
    page: int = Field(..., description="当前页码")
    limit: int = Field(..., description="每页数量")
    total: int = Field(..., description="总搜索记录数")
